package 测试;

import java.util.*;

class student{
    public String name;

    public student(String name) {
        this.name = name;
    }
}
public class Test {
    public static void main(String[] args) {

        ArrayList <Integer>arrayList = new ArrayList<>();
        arrayList.add(1);

    }

    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String str = scanner.nextLine();
            Deque<Character> stack = func(str);
           if(stack.isEmpty()) {
               System.out.println(0);
           }else {
               for (int i = 0; i < stack.size(); i++) {
                   System.out.println(stack.pop());
               }
           }
        }
    }

    private static Deque<Character> func(String str) {
        //两个栈实现
        StringBuilder stringBuilder = new StringBuilder(str);
        Deque<Character> stack1 = new LinkedList<>();
        Deque<Character> stack2 = new LinkedList<>();
        for (int i = 0; i < stringBuilder.length(); i++) {
            stack1.push(stringBuilder.charAt(i));
        }
        while (!stack1.isEmpty()){
            char ch = stack1.pop();
            if(!stack1.isEmpty() && stack1.peek().equals(ch)) {
                //如果相等就弹出
                stack1.pop();
            }else if(!stack2.isEmpty() && stack2.peek().equals(ch)){
                stack2.pop();
            }else {
                stack2.push(ch);
            }
        }
        return stack2;
    }
    public boolean isSubsequence1(String S, String T) {
        // write code here
        //判断T中是否包含S
        Set<Character> set1 = new TreeSet<>();
        for (char x:T.toCharArray()) {
            //x入哈希
            set1.add(x);
        }
        for(int i = 0;i<S.length();i++) {
            if(!set1.contains(S.charAt(i))) {
                return false;
            }
            System.out.println();
            System.out.println();
            System.out.println();
            System.out.println();
            System.out.println();
            System.out.println();
            System.out.println();
            System.out.println();


        }
        return true;
    }
    //判断子序列
    public boolean isSubsequence (String S, String T) {
        // write code here
        //判断T中是否包含S
        Set<Character> set1 = new TreeSet<>();
        for (char x:S.toCharArray()) {
            //x入哈希
            set1.add(x);
        }
        Set<Character> set2 = new TreeSet<>();
        for (char x:T.toCharArray()) {
            set2.add(x);
        }
       return set1.containsAll(set2);
       /* for (int i = 0; i < T.length(); i++) {
            //判断该字符是否在S中包含
            if(!set1.contains(T.charAt(i))) {
                return false;
            }
        }*/

    }
    public static void main2(String[] args) {
        Random random = new Random();
        Scanner scanner = new Scanner(System.in);
        int p = random.nextInt(100);//(0包含，指定值不包含，所以+1，如果是0就变成1，如果是99就变成100)
        int size = 0;
       while (scanner.hasNextLine()) {
          int z = scanner.nextInt();
           if(z > p) {
               System.out.println("猜大了第"+(++size)+"次");
           }else if(z < p){
               System.out.println("猜小了第"+(++size)+"次");
           }else {
               System.out.println("第"+(++size)+"猜对了");
               break;
           }
        }
    }
}
